def rc_decode(rcID):    
    """
    将rcID转化为normalID
    :param：rcID编号 字符串
    ：return：normalID 字符串
    """
    count=0
    normalID=""
    if rcID[0] == "R":
        for i in rcID:
            if i == "C":
                count = count + 1
        if count == 1:
            wz=rcID.index("C")
            number=int(rcID[wz+1:])
            while(number>26):
                if number>26:
                    remainder=number%26
                    if remainder==0:
                        remainder=26
                    normalID=chr(remainder+64)+normalID
                    number=int((number-remainder)/26)     
            if number<=26:
                normalID=chr(number+64)+normalID       
                normalID=normalID+rcID[1:wz]
        else:
            normalID="格式错误"
    else:
        normalID="格式错误"
    return normalID
if __name__ == '__main__':
    n=int(input("输入要处理几个代码："))
    nuber=[]
    while(n!=0):
        n-=1
        nuber.append(input("请输入cID码:"))        
    for i in nuber:        
        print(rc_decode(i))